<?php
define('ROOT_DIR', $_SERVER['DOCUMENT_ROOT'].'/');
$path = ROOT_DIR.'setting.php';
$settingsContent = file_get_contents($path);
$a = (int)$_POST['a'];
$b = (int)$_POST['b'];
$c = (int)$_POST['c'];
$d = (int)$_POST['d'];
$e = (int)$_POST['e'];
$f = (int)$_POST['f'];
$g = (int)$_POST['g'];
$newSettingMailArray = <<<EOT
\$speed_download_arr = array( 
    'a' => $a,
    'b' => $b,
    'c' => $c,
    'd' => $d,
    'e' => $e,
    'f' => $f,
    'g' => $g
);
EOT;
$pattern = '/\$speed_download_arr\s*=\s*array\s*\(\s*[^;]*\s*\);/s';
$replacement = $newSettingMailArray;
$updatedSettingsContent = preg_replace($pattern, $replacement, $settingsContent);
file_put_contents($path, $updatedSettingsContent);
echo '<script>alert("修改成功");window.location.href="../../pzsetting.php?s=download";</script>';